using System;
using CommandSystem;

namespace RgCore.Commands.ModuleCommands
{
    [CommandHandler(typeof(RemoteAdminCommandHandler))]
    public class ModuleCommand : ParentCommand
    {
        public ModuleCommand() => LoadGeneratedCommands();
        public override string Command => "modulemanager";

        public override string[] Aliases => new string[] { "mm" };

        public override string Description => "集成插件控制";

        public override void LoadGeneratedCommands()
        {
            this.RegisterCommand(new List());
            this.RegisterCommand(new Reload());
            this.RegisterCommand(new Load());
            this.RegisterCommand(new Unload());
            this.RegisterCommand(new Enable());
            this.RegisterCommand(new Disable());
        }

        protected override bool ExecuteParent(ArraySegment<string> arguments, ICommandSender sender,
            out string response)
        {
            if (!sender.CheckPermission(PlayerPermissions.ServerConsoleCommands))
            {
                response = "你没有权限执行此命令";
                return false;
            }

            response = "用法: modulemanager/mm <enable/disable/load/reload/unload/list> <文件名/插件ID>";
            return false;
        }
    }
}